import threading
import time

def fun1(delay):
    print('开始运行fun1,线程名字：{}'.format(threading.current_thread().getName()))
    time.sleep(delay)
    print('运行fun1结束')

def fun2(delay):
    print('开始运行fun2,线程名字：{}'.format(threading.current_thread().getName()))
    time.sleep(delay)
    print('运行fun2结束')

class MyTherd(threading.Thread):
    def __init__(self,func,name,args):
        super().__init__(target=func,name=name,args=args)

    def run(self):
        # self._target() 这样执行会报错
        self._target(*self._args)


if __name__ == "__main__":
    print('开始运行')
    t1 = MyTherd(fun1,'thread-1',(2,))
    t2 = MyTherd(fun2,'thread-2',(4,))
    t1.start()
    t2.start()
    t1.join()
    t2.join()
    print('ending...')
